package com.mask.thread.pk02;

import java.util.concurrent.TimeUnit;

/**
 * @author hx
 * @since 2021/12/2 2:00 下午
 */

public class MyThread2 extends Thread{
    private Object lock;

    public MyThread2(Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        synchronized (lock) {
            System.out.println("开始notify时间："+ System.currentTimeMillis());
            lock.notifyAll();
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("结束notify时间：" + System.currentTimeMillis());
        }
    }
}
